using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Admin_FeedBack : System.Web.UI.UserControl
{
    processFeedback pFeedback;
    protected void Page_Load(object sender, EventArgs e)
    {
        pFeedback = new processFeedback();

        Load_gvwFeedback();
        pnlDetail.Visible = false;
    }

    private void Load_gvwFeedback()
    {
        gvwFeedback.DataSource = pFeedback.ListFeedback();
        gvwFeedback.DataBind();
    }
    protected void gvwFeedback_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvwFeedback.PageIndex = e.NewPageIndex;        
        Load_gvwFeedback();
    }
    
    protected void gvwFeedback_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        string FeedbackID = gvwFeedback.DataKeys[e.NewSelectedIndex].Value.ToString();
        pnlDetail.Visible = true;
        lblDetail.Text = pFeedback.getFeedbackDetailByID(FeedbackID);        
    }
    protected void gvwFeedback_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            string FeedbackID = gvwFeedback.DataKeys[e.RowIndex].Value.ToString();
            if (pFeedback.deleteFeedback(FeedbackID) > 0)
            {
                Load_gvwFeedback();
            }
        }
        catch (Exception)
        {
            Alert.Show("This paymney type is being used, you can not delete!");
        }  
    }
}
